package demo;

import java.io.UnsupportedEncodingException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.jfinal.handler.Handler;

import io.undertow.server.HttpHandler;
import io.undertow.server.HttpServerExchange;
import io.undertow.util.Headers;

public class MyHandler extends Handler   {

    

	@Override
	public void handle(String target, HttpServletRequest request, HttpServletResponse response, boolean[] isHandled) {
		try {
            request.setCharacterEncoding("UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        
        // 设置响应编码为 UTF-8
        response.setCharacterEncoding("UTF-8");
        response.setContentType("text/html,text/css;charset=UTF-8");
        
        // 执行下一个 Handler
        next.handle(target, request, response, isHandled);
		
	}
}
